/**
 * Created by yangfan on 2016/11/22.
 */
define(['config/appregister',"i18n","business/myResume/services/httpServices","business/services/components"],function(app,i18n,httpServices){
    app.controller('resumeCollectJobCtrl', function($scope,$state) {
        $scope.i18n = i18n;
        $scope.listParams = {
            pageNo:1,
            pageSize:30
        };
        $scope.job = "";
        $scope.dialogModel = {
            content:"您确定要取消收藏吗？",
            isShow:false,
            confirm:function(){
                cancle();
            }
        }
        
        //收藏与取消收藏
        $scope.cancleCollect = function(jobId){
        	$scope.dialogModel.isShow = true;
        	$scope.job = jobId;
        }
        function cancle(){
        	var req = {
                type:"POST",
                uri:"update",
                data:{
                    fkId:$scope.job,
                    type:'3'
                }
            };
            httpServices.collectServices(req).success(function(response){
                $scope.$apply(function(){
                   getList()
                });
            }).error(function(){})
        }

        $scope.tableTitle = ["职位","公司名称","工作地点","薪资","发布日期","操作"];
        function getList(){
            var req = {
                type:"GET",
                uri:"getMyCollectionJob",
                data:{
                    pageNo:$scope.listParams.pageNo,
                    pageSize:$scope.listParams.pageSize,
                    type:0,
                    keyWord:null
                }
            };
            httpServices.jobServices(req).success(function(response){
                $scope.$apply(function(){
                    $scope.jobList = response.data.list;
                    $scope.totalItem = response.data.Pagination.totalCount;
                    getPage();
                });
            }).error(function(){})
        }
        function getPage(){
            $scope.paginationConf = {
                currentPage: $scope.listParams.pageNo,
                totalItems: $scope.totalItem,
                //每页预览条数
                itemsPerPage: $scope.listParams.pageSize,
                //分页总数
                numberOfPages:Math.ceil($scope.totalItem/$scope.listParams.pageSize),
                // 实际分页长度
                pagesLength:5,
                perPageOptions: [10, 20, 30, 40, 50],
                onChange: function () {
                    $scope.list = [];
                    $scope.listParams.pageNo = $scope.paginationConf.currentPage;
                    getList();
                }
            };
            $scope.everPageShow = $scope.paginationConf.perPageOptions;

        }
        getList()
    })
});